package com.atguigu.dga.util;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class HttpUtil {

    private static OkHttpClient client=getClient();

    private static OkHttpClient getClient(){return new OkHttpClient() ;}

    public static String get(String utl){
        //构建一个get请求对象
        Request.Builder builder = new Request.Builder();
        Request build = builder.get().url(utl).build();

        //发送请求
        Call call = client.newCall(build);

        try {
            //获取请求返回值
            Response execute = call.execute();
            return execute.body().string();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

    public static void main(String[] args) {
        String s = get("http://hadoop102:18080/api/v1/applications/application_1675762731453_0002");
        System.out.println(s);
    }
}
